package com.xgq.drink.mapper;

import com.xgq.drink.entity.Payment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xgq
 * @since 2025-03-04
 */
public interface PaymentMapper extends BaseMapper<Payment> {
    @Select("SELECT DATE_FORMAT(payment_time, '%Y-%m-%d') AS date, SUM(payment_amount) AS amount " +
            "FROM payment " +
            "WHERE payment_time BETWEEN #{startTime} AND #{endTime} " +
            "GROUP BY DATE_FORMAT(payment_time, '%Y-%m-%d')")
    List<Map<String, Object>> selectDailyPaymentAmounts(@Param("startTime") LocalDateTime startTime,
                                                        @Param("endTime") LocalDateTime endTime);
}
